global indata "/.../data"
global output "/.../output"
set more off
set linesize 255

*-----------------------------------------------------------------------------------
* Author: Dhiren Patki
*
* This program shows the fraction of total DB sponsoring employers and active ptcp 
* where the employer either sponsors just one plan, or sponsors multiple plans 
* that are either never frozen or are frozen all at the same time.
* The input file is produced in 09a_multiplanlossstat.sas
*-----------------------------------------------------------------------------------

*Loss to multiplan employer restriction

import delimited using $indata/multiplan_cratio.csv, stringcols(2) clear
gen not_lost = lost_to_multiplan==0

matrix restr_c=J(1,3,.)

sum not_lost
matrix restr_c[1,1]=r(N)
matrix restr_c[1,2]=r(mean)
sum not_lost [aw=total_active_ptcp]
matrix restr_c[1,3]=r(mean)

*Output table
clear
svmat restr_c
rename restr_c1 firmyrcnt
rename restr_c2 firmrt
rename restr_c3 firmrt_ptcpwt
label var firmyrcnt "Firm-years"
label var firmrt "Frac firms retained"
label var firmrt_ptcpwt "Ptcp wtd frac firms retained"
export delimited $output/restrrate.csv, datafmt replace




